<!-- 会员卡-免费餐品 -->
<template name="freeGoodsList">
	<view class="container">
		<qrcodeMask ref="qrcodeMask" :content="content" title="餐品码"></qrcodeMask>
		<view class="free-goods margin" v-for="(item,index) in listData" v-bind:key="index" v-if="index<max||max==0">
			<view class="free-goods-header">
				<image :src="url+'/static/imgs/free-bg.png'" class="bg"></image>
				<view class="row free-goods-main">
					<view class="title row">{{item.goods_info.name}}</view>
					<view class="col tips-text">
						<view class="row">
							<text>一份</text>
							<image @click="changeFreeGoodsMask" :data-index="index" class="qrcode-color auto-left" :src="url+'/static/imgs/member-card/qrcode-color.png'"></image>
						</view>
						<text>有效期：{{item.create_time}}~{{item.end_time}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import qrcodeMask from './qrcodeMask.vue';
	var app = getApp();
	export default {
		name: 'freeGoodsList',
		data() {
			return {
				url: app.globalData.baseImgUrl,
				content: ''
			};
		},
		props: {
			listData: {
				type: Array
			},
			max: {
				type: Number,
				default: 0
			}
		},
		components: {
			qrcodeMask
		},
		methods: {
			//展示免费餐品二维码
			changeFreeGoodsMask: function(e) {
				var that = this;
				var index = e.currentTarget.dataset.index;
				that.content = escape('order_type=1&id=' + that.listData[index].id);
				console.log(that.content)
				that.$refs.qrcodeMask.changeMask();
			},
		}
	}
</script>

<style scoped>
	/* 免费餐品 */
	.free-goods-header {
		width: 100%;
		height: 202rpx;
		margin-top: 20rpx;
		position: relative;
	}

	.free-goods-header .bg {
		width: 100%;
		height: 100%;
	}

	.free-goods-header .free-goods-main {
		position: absolute;
		top: 0rpx;
		left: 0rpx;
		height: 202rpx;
		align-items: center;
		justify-content: space-between;
	}

	.free-goods-header .free-goods-main .title {
		font-weight: Demibold;
		color: #fff;
		font-size: 36rpx;
		width: 220rpx;
		height: 140rpx;
		color: #fff;
		text-align: center;
		align-items: center;
		justify-content: center;
	}

	.free-goods-header .tips-text {
		margin-left: 32rpx;
	}

	.free-goods-header .tips-text text:nth-child(1) {
		color: #333333;
		font-size: 32rpx;
	}

	.free-goods-header .tips-text text:nth-child(2) {
		color: #999999;
		font-size: 28rpx;
		margin-top: 28rpx;
	}

	.qrcode-color {
		width: 38rpx;
		height: 38rpx;
	}
</style>
